﻿import QtQuick 2.12
import QtQuick 2.9
import QtQuick.Controls 2.2
import TaoQuick 1.0
import Top 1.0
import Qt.labs.platform 1.1

Item {
    anchors.fill: parent
    MoviePlayClient{
        id:moviceId
        visible: false
    }

    Column {
        anchors.horizontalCenter: parent.horizontalCenter
        CusLabel {
            text:"消息框："
            font.bold: true
            font.pixelSize: 18
        }

        ScrollView {
            width: 580
            height: 250
            anchors.horizontalCenter: parent.horizontalCenter
            //裁剪，把超出边框的一部分减掉
            clip: true
            TextArea {
                id: displayInfoId
                verticalAlignment: Text.AlignTop
                horizontalAlignment: Text.AlignLeft
                leftPadding: 10
                topPadding: 10
                color: "black"
                font.pixelSize: 16
                readOnly: true
                selectByMouse: true
                textFormat: TextEdit.RichText
                selectedTextColor: "#1fBFC0"
                text: GlobalManager.tcpClientManager.transferProxy.comInfo
                wrapMode: TextEdit.WrapAnywhere
                cursorPosition: text.length
                background: Rectangle {
                    color: "#3069b7eb"
                    radius: 10
                    border.width: 2
                    border.color: "white"
                }
                onLinkActivated: {
                    moviceId.moviePath = link
                    moviceId.visible = true
                }
            }
        }
        Row {
            spacing: 50
            CusLabel {
                text:"输入框："
                font.bold: true
                font.pixelSize: 20
                anchors.bottom: parent.bottom
            }
            CusButton_ImageBackground {
                height: 40
                width: 40
                btnImgUr: "qrc:/Image/openFile.png"
                anchors.bottom: parent.bottom
                onClicked: {
                    fileDialogId.open()
                }
                FileDialog {
                    id: fileDialogId
                    onAccepted: {
                        console.log("path = " + fileDialogId.currentFile)
                        GlobalManager.tcpClientManager.transferProxy.sendImage(fileDialogId.currentFile)
                    }
                }
            }
            CusButton_ImageBackground {
                height: 40
                width: 40
                btnImgUr: "qrc:/Image/fries.png"
                anchors.bottom: parent.bottom
                onClicked: {
                    fileDialogId1.open()
                }
                FileDialog {
                    id: fileDialogId1
                    onAccepted: {
                        console.log("path = " + fileDialogId1.currentFile)
                        GlobalManager.tcpClientManager.transferProxy.sendMovie(fileDialogId1.currentFile)
                    }
                }
            }
            CusButton_ImageBackground {
                height: 40
                width: 40
                btnImgUr: "qrc:/Image/Clrear.png"
                anchors.bottom: parent.bottom
                onClicked: {
                    GlobalManager.tcpClientManager.comInfo=""
                    GlobalManager.tcpClientManager.removeFile();
                }
            }
        }
        ScrollView {
            width: 580
            height: 100
            y:20
            anchors.horizontalCenter: parent.horizontalCenter
            TextArea {
                id: sendMessageInfoId
                verticalAlignment: Text.AlignTop
                horizontalAlignment: Text.AlignLeft
                leftPadding: 10
                topPadding: 10
                color: "black"
                font.pixelSize: 16
                selectByMouse: true
                selectedTextColor: "#1fBFC0"
                wrapMode: TextEdit.WrapAnywhere
                cursorPosition: text.length
                background: Rectangle {
                    color: "transparent"
                    border.width: 1
                    radius: 5
                    border.color: "black"
                }
            }
        }
        Item {
            height: 50
            width: 580
            CusButton {
                anchors.left: parent.left
                anchors.bottom: parent.bottom
                text: "返回"
                height: 35
                width: 100
                onClicked: {
                    tcpClient.displayIndex=0
                    //让他重新登录
                    GlobalManager.tcpClientManager.replyCode = -100086
                    GlobalManager.tcpClientManager.disconectClient();
                }
            }
            CusButton {
                anchors.right: parent.right
                anchors.bottom: parent.bottom
                text: "发送"
                height: 35
                width: 100
                onClicked: {
                    GlobalManager.tcpClientManager.transferProxy.sendTextInfo(sendMessageInfoId.text)
                    sendMessageInfoId.text = ""
                }
            }
        }
    }
}

